#include <iostream>
#include <memory>
#include "auto_ptr.hpp"
using namespace std;
template<class T>
class Auto_ptr1
{
public:
	Auto_ptr1(T* ptr = nullptr):_ptr(ptr){}
	~Auto_ptr1()
	{
		if(_ptr != nullptr)
		{
			delete _ptr;
			_ptr = nullptr;
		}
	}
	Auto_ptr1(Auto_ptr1<T>& ptr)
		:_ptr(ptr._ptr)
	{
		ptr._ptr = nullptr;
	}
	
	Auto_ptr1<T>& operator=(Auto_ptr1<T>& ptr)
	{
		if(this != &ptr)
		{
			delete _ptr;
			_ptr = ptr._ptr;
			ptr._ptr = nullptr;
		}
		return *this;
	}
	T& operator*()
	{
		return *_ptr;
	}
	T* operator->()
	{
		return _ptr;
	}
private:
	T* _ptr;
};

int main()
{
	//shared_ptr<int> x(new int(1));
	//shared_ptr<int> y;
	//y = x;
	//cout << *y << endl;
	Auto_ptr1<int> x(new int(1));
	Auto_ptr1<int> y(new int(2));
	x = y;
	cout << *x << endl;
	//cout << *y << endl;
	//test();
	return 0;

}
